layui.use(['element', 'table', 'jquery', 'form'], function () {
    var element = layui.element;
    var table = layui.table;
    var $ = layui.jquery;
    var form = layui.form;

    //下拉框
    dropDownBox();

    function dropDownBox() {
        $.ajax({
            url: "/courseClass/getCourseClass",
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var d = eval(data.data);
                $('#title').append("<option value=''>选择分类类型</option>")
                for (var i = 0; i < d.length - 1; i++) {
                    var id = d[i].categroyId;
                    var name = d[i].title;
                    $('#title').append("<option value='" + id + "'>" + name + "</option>")
                }
                form.render('select');
            }
        });
    }

    //检索
    form.on('submit(sub)', function (data) {
        var courseNprice = $('input[name=courseNprice]').val();
        if (!(/(^[1-9]\d*$)/.test(courseNprice)) && courseNprice != '') {
            layer.msg("价格请输入正整数");
            $('input[name=courseNprice]').val('');
            return false;
        }
        $.ajax({
            url: '/course/getRetrievalCourse',
            type: 'post',
            data: data.field,
            async: false,
            dataType: 'json',
            success: function (data) {
                parent.tablereload(data.data);//访问父页面方法
                var layer = parent.layer;
                layer.close(layer.index);
            }
        });
    })
})